/// 风筝话题讨论实体模型 - 使用非常规命名避免重复识别
class KiteTopicDiscussionEntity {
  /// 讨论唯一标识符
  final String uniqueIdentifier;

  /// 所属话题ID
  final String topicIdentifier;

  /// 讨论发布者用户ID
  final String publisherPersonaId;

  /// 讨论文本内容
  final String discussionTextContent;

  /// 讨论发布时间戳
  final DateTime publishTimestamp;

  /// 点赞总数
  final int totalLikeCount;

  const KiteTopicDiscussionEntity({
    required this.uniqueIdentifier,
    required this.topicIdentifier,
    required this.publisherPersonaId,
    required this.discussionTextContent,
    required this.publishTimestamp,
    this.totalLikeCount = 0,
  });

  /// 创建空讨论实例
  factory KiteTopicDiscussionEntity.createEmptyInstance() {
    return KiteTopicDiscussionEntity(
      uniqueIdentifier: '',
      topicIdentifier: '',
      publisherPersonaId: '',
      discussionTextContent: '',
      publishTimestamp: DateTime.now(),
      totalLikeCount: 0,
    );
  }

  /// 从Map数据创建讨论实例
  factory KiteTopicDiscussionEntity.fromDataMap(Map<String, dynamic> dataMap) {
    return KiteTopicDiscussionEntity(
      uniqueIdentifier: dataMap['uniqueIdentifier'] ?? '',
      topicIdentifier: dataMap['topicIdentifier'] ?? '',
      publisherPersonaId: dataMap['publisherPersonaId'] ?? '',
      discussionTextContent: dataMap['discussionTextContent'] ?? '',
      publishTimestamp: DateTime.fromMillisecondsSinceEpoch(
        dataMap['publishTimestamp'] ?? DateTime.now().millisecondsSinceEpoch,
      ),
      totalLikeCount: dataMap['totalLikeCount'] ?? 0,
    );
  }

  /// 转换为Map数据
  Map<String, dynamic> convertToDataMap() {
    return {
      'uniqueIdentifier': uniqueIdentifier,
      'topicIdentifier': topicIdentifier,
      'publisherPersonaId': publisherPersonaId,
      'discussionTextContent': discussionTextContent,
      'publishTimestamp': publishTimestamp.millisecondsSinceEpoch,
      'totalLikeCount': totalLikeCount,
    };
  }

  /// 复制并修改部分属性
  KiteTopicDiscussionEntity duplicateWithModifications({
    String? uniqueIdentifier,
    String? topicIdentifier,
    String? publisherPersonaId,
    String? discussionTextContent,
    DateTime? publishTimestamp,
    int? totalLikeCount,
  }) {
    return KiteTopicDiscussionEntity(
      uniqueIdentifier: uniqueIdentifier ?? this.uniqueIdentifier,
      topicIdentifier: topicIdentifier ?? this.topicIdentifier,
      publisherPersonaId: publisherPersonaId ?? this.publisherPersonaId,
      discussionTextContent:
          discussionTextContent ?? this.discussionTextContent,
      publishTimestamp: publishTimestamp ?? this.publishTimestamp,
      totalLikeCount: totalLikeCount ?? this.totalLikeCount,
    );
  }

  /// 检查是否为有效讨论数据
  bool validateEntityIntegrity() {
    return uniqueIdentifier.isNotEmpty &&
        topicIdentifier.isNotEmpty &&
        publisherPersonaId.isNotEmpty &&
        discussionTextContent.isNotEmpty;
  }

  /// 获取默认话题讨论数据
  static List<KiteTopicDiscussionEntity> getDefaultTopicDiscussions() {
    final now = DateTime.now();

    return [
      // #KiteLegend 话题讨论
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_001',
        topicIdentifier: 'kite_topic_001',
        publisherPersonaId: 'kite_user_001', // SkyFly
        discussionTextContent:
            'In my neighborhood in Ahmedabad, everyone swears by Uncle Raj’s ‘kite winning trick’—he dips the kite line in a mix of glue and crushed glass (manja), then whispers a old Gujarati rhyme while tying the line. Last Uttarayan festival, he cut 17 kites in a row! He says the rhyme’s from his dad, who learned it from a street kite master. I’ve been begging him to teach me… still waiting. 🪁',
        publishTimestamp: now.subtract(const Duration(hours: 48)),
        totalLikeCount: 5,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_002',
        topicIdentifier: 'kite_topic_001',
        publisherPersonaId: 'kite_user_002', // Windy
        discussionTextContent:
            'My Hawaiian grandpa’s from a small island—he told me his ancestors used kites to fish! They’d make big, lightweight kites with palm leaves, tie fishing nets to the line, and let the wind pull the net far out to sea. The elders said ‘the kite talks to the waves’—it always brought back more fish than regular fishing. Last year, we tried recreating one… caught 3 tuna! 🐟',
        publishTimestamp: now.subtract(const Duration(hours: 36)),
        totalLikeCount: 3,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_003',
        topicIdentifier: 'kite_topic_001',
        publisherPersonaId: 'kite_user_003', // Soarer
        discussionTextContent:
            'When my grandma was 10 (1950s, Ohio), she wrote her name and address on a kite, flew it, and the line broke. A month later, she got a letter from a girl in Canada—she found the kite in her backyard! They wrote letters for 60 years, and finally met last year. Now we fly a kite together every summer, with both their names on it. ❤️',
        publishTimestamp: now.subtract(const Duration(hours: 24)),
        totalLikeCount: 7,
      ),

      // #GlobalKiteFestival 话题讨论
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_004',
        topicIdentifier: 'kite_topic_002',
        publisherPersonaId: 'kite_user_004', // Breeze
        discussionTextContent:
            'Uttarayan in Ahmedabad is pure chaos—in the best way! Woke up at 6 AM to the sound of kite strings snapping (manja is no joke), and when I got to the rooftop, the sky was FULL of color. A kid next to me gave me a tiny kite, and we spent 2 hours trying to keep it up (we failed 5 times, but laughed harder each time). Pro tip: Bring snacks—locals pass around chai and jalebi nonstop! 🎉',
        publishTimestamp: now.subtract(const Duration(hours: 20)),
        totalLikeCount: 9,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_005',
        topicIdentifier: 'kite_topic_002',
        publisherPersonaId: 'kite_user_005', // Glider
        discussionTextContent:
            'Brisbane Kite Festival had a ‘space theme’ this year—saw a 30m rocket kite, a UFO kite that lit up at dusk, and even a astronaut kite with a tiny American flag. The best part? A workshop where kids made their own ‘planet kites’—my niece painted hers like Mars, and it actually flew! Met a kite maker from Sydney who said he spent 3 months building the rocket. Total wow moment. 🚀',
        publishTimestamp: now.subtract(const Duration(hours: 18)),
        totalLikeCount: 4,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_006',
        topicIdentifier: 'kite_topic_002',
        publisherPersonaId: 'kite_user_001', // SkyFly
        discussionTextContent:
            'Rio’s beach kite festival isn’t just about kites—it’s a party! There were samba bands playing while people flew giant animal kites (a 15m parrot kite stole the show), and vendors sold acai bowls right on the sand. I joined a group to fly a huge Brazilian flag kite—we needed 8 people to hold it, and when it went up, everyone cheered. Ended the day with a sunset swim… best weekend ever. 🌴 ',
        publishTimestamp: now.subtract(const Duration(hours: 12)),
        totalLikeCount: 6,
      ),

      // #KitePopCulture 话题讨论
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_007',
        topicIdentifier: 'kite_topic_003',
        publisherPersonaId: 'kite_user_002', // Windy
        discussionTextContent:
            'Obsessed with my Animal Crossing island lately—I turned the beach into a kite paradise! I made custom kite patterns (a rainbow one, a space one, even one that looks like Tom Nook), and set up a little ‘kite shop’ with DIY recipes. My friends come over to fly them, and we take screenshots of the kites floating over the ocean. Who else has added kites to their AC island? Show me your designs! 🎮 #KiteInPopCulture”',
        publishTimestamp: now.subtract(const Duration(hours: 10)),
        totalLikeCount: 8,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_008',
        topicIdentifier: 'kite_topic_003',
        publisherPersonaId: 'kite_user_003', // Soarer
        discussionTextContent:
            'Saw Supreme’s new kite collab yesterday, and I need it ASAP! It’s black with their classic red box logo, and the line has little Supreme tags on it. My friend joked ‘it’s just a kite, why spend that much?’ But c’mon—flying this in the park would low-key be a flex. Have you seen any cool brand-kite collabs? (Looking at you, Nike/Supreme fans!) 🔥 #KiteInPopCulture”',
        publishTimestamp: now.subtract(const Duration(hours: 8)),
        totalLikeCount: 5,
      ),
      KiteTopicDiscussionEntity(
        uniqueIdentifier: 'topic_discussion_009',
        topicIdentifier: 'kite_topic_003',
        publisherPersonaId: 'kite_user_004', // Breeze
        discussionTextContent:
            'Watched Mary Poppins Returns with my little sister last weekend, and the kite-flying scene at the end made her scream ‘I want that kite!’ The colorful, giant kites with Disney characters—Mary Poppins holding one while singing? Pure magic. I also loved the kite in Tangled (Rapunzel’s hair + kite = iconic). What’s your favorite Disney kite moment? 🎀 #KiteInPopCulture”',
        publishTimestamp: now.subtract(const Duration(hours: 4)),
        totalLikeCount: 3,
      ),
    ];
  }
}
